// 测试 API 导入和使用
import { jobApi, type HirePagination } from './api/index.ts'

console.log('API 模块加载成功:', jobApi)

// 测试获取招聘列表
const params: HirePagination = {
  type: 'progress',
  currentPage: 1,
  pageSize: 10
}

jobApi.getListToApp(params).then(res => {
  console.log('招聘列表响应:', res)
}).catch(error => {
  console.error('获取招聘列表失败:', error)
}) 

// 测试 getChangeLaborSignMessage 接口
import { applicationApi } from './api/api-helper.js'

// 模拟测试数据
const testData = {
  openId: 'test_open_id_123',
  date: '2025-01-20',
  recruitUseId: 'recruit_001',
  recruitUseEntryId: 'entry_001'
}

// 测试接口调用
async function testGetChangeLaborSignMessage() {
  try {
    console.log('开始测试 getChangeLaborSignMessage 接口...')
    console.log('请求参数:', testData)
    
    const result = await applicationApi.getChangeLaborSignMessage(testData)
    
    console.log('接口调用成功:', result)
    
    if (result && result.code === 200) {
      console.log('✅ 接口返回成功')
      console.log('hasExistingSignup:', result.data?.hasExistingSignup)
      console.log('原岗位信息:', result.data?.previousSignup)
    } else {
      console.log('❌ 接口返回失败:', result?.msg)
    }
  } catch (error) {
    console.error('❌ 接口调用异常:', error)
  }
}

// 模拟接口返回数据
const mockResponse = {
  code: 200,
  msg: 'success',
  data: {
    hasExistingSignup: true,
    previousSignup: {
      company: '东莞高步电子厂',
      position: '不体检 普通工衣',
      salary: '22元/时',
      address: '广东省东莞市高埗镇',
      hireRecruitUseId: 'recruit_old_001',
      hireRecruitUseEntryId: 'entry_old_001',
      createdAt: '2025-01-15T10:00:00Z'
    }
  }
}

console.log('模拟接口返回数据:', mockResponse)

// 导出测试函数
export { testGetChangeLaborSignMessage } 